// pages/editDetails/editDetails.ts
Page({
  /**
   * 页面的初始数据
   */
  data: {
    listId: "", // 接收参数
    details: <any>[], // 头部banner图
    detailsList: <any>[], // 歌曲列表
    comments: <any>[], // 精彩评论
  },
  // 接收
  onLoad: function (options: any) {
    this.setData({
      listId: options.ids,
    });
    /* 歌曲列表 拼接的时候可以用this.data.listId也可以用options.ids*/
    wx.request({
      url: `http://localhost:3000/playlist/detail?id=${options.ids}`,
      success: (res) => {
        // console.log(res.data);
        this.setData({
          details: res.data,
          detailsList: (res.data as any).playlist.tracks.slice(0, 10),
        });
      },
    });

    /* 精彩评论 */
    wx.request({
      url: `http://localhost:3000/comment/playlist?id=${this.data.listId}&offset=1&limit=10`,
      success: (res) => {
        // console.log((res.data as any).comments);
        this.setData({});
        this.setData({
          comments: (res.data as any).comments,
        });
      },
    });
  },
});
